﻿using System.Diagnostics;

namespace Device
{
    internal class ShellExecute
    {
        public static void Run(string cmd)
        {
            Process process = new Process();

            // 指定要运行的命令和参数
            process.StartInfo.FileName = "cmd.exe";
            process.StartInfo.Arguments = "/C " + cmd;

            // 设置一些其他属性，如是否显示窗口等
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.RedirectStandardOutput = true;

            // 启动进程
            process.Start();

            // 读取命令的输出
            //string output = process.StandardOutput.ReadToEnd();f

            // 等待进程完成
            process.WaitForExit();

            // 打印输出
            //Console.WriteLine("Command Output: " + output);
        }
    }
}